﻿using Business.Service;
using Model;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Newtonsoft.Json;


namespace MvcAppWeb.Controllers
{
    public class QualityWOCController : BaseDataController
    {
        //
        // GET: /QualityWOC/

        public ActionResult QualityWOC()
        {
            if (Session["UserInfo"] == null) return RedirectToAction("LogOn", "Account");
            else
            {
                AppUserList model = (AppUserList)Session["UserInfo"];
                return View(model);

            }
        }

        ///<summary>
        ///查询质检商品信息
        ///</summary>
        ///<returns></returns>
        public JsonResult InitJsonResult(string BatchNo = "", string GoodsCode = "", string GoodsName = "", string Qualitytype = "0", string Result = "0")
        {

            string where = " where 1=1 ";
            int page = int.Parse(Request["page"].ToString());
            int rows = int.Parse(Request["rows"].ToString());
            int total = 0;

            if (BatchNo != "")
            {
                where += "   and a.BatchNo='" + BatchNo + "') ";
            }
            if (GoodsCode != "")
            {
                where += "   and g.GoodsCode='" + GoodsCode + "'";
            }
            if (GoodsName != "")
            {
                where += "   and g.GoodsName='" + GoodsName + "'";
            }
            if (!Qualitytype.Equals("0"))
            {
                where += " and a.Qualitytype='" + Qualitytype.Trim() + "' ";
            }
            if (!Result.Equals("0"))
            {
                where += " and a.inspectresult='" + Result + "' ";
            }

            var retData = new object();
            BQuality db = new BQuality();
            retData = db.GetQualityWOCList(page, rows, out total, where).ToList();
            Dictionary<string, object> json = new Dictionary<string, object>();
            json.Add("total", total);
            json.Add("rows", retData);
            return Json(json);
        }

    }
}
